<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePackagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('packages', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('套餐表');
            $table->integer('shop_id')->comment('商店id');
            $table->string('title')->comment('标题');
            $table->string('subtitle')->nullable()->comment('副标题');
            $table->string('image')->nullable()->comment('主图');
            $table->text('content')->nullable()->comment('内容(图文介绍)');
            $table->string('service_time')->nullable()->comment('服务时间');
            $table->decimal('price', 8, 2)->default('0.00')->comment('价格');
            $table->tinyInteger('stock_amount')->default(0)->comment('库存');
            $table->tinyInteger('view_amount')->default(0)->comment('浏览量');
            $table->tinyInteger('sell_amount')->default(0)->comment('成交量');
            $table->tinyInteger('sort')->default(0)->comment('排序');
            $table->boolean('is_show')->default(true)->comment('是否展示');
            $table->timestamps();
        });

        Schema::create('package_products', function (Blueprint $table) {
            $table->integer('package_id')->comment('套餐id');
            $table->integer('product_id')->comment('产品id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('packages');
        Schema::dropIfExists('package_products');
    }
}
